/**
 * 
 */
package com.peppa.gmf.runtime.diagram.ui.extension.rotatable.editPart.listener;

import org.eclipse.draw2d.FigureListener;
import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.NodeListener;

/**
* @author peppa E-mail: pe_ppa@163.com
* @date 2023年11月22日 下午11:46:48
*/
public class PropagateFigureListenerAtConnectionFigure implements NodeListener {

	private FigureListener figureListener;

	/**
	 * Constructor.
	 */
	public PropagateFigureListenerAtConnectionFigure(FigureListener figureListener) {
		this.figureListener = figureListener;
	}

	/**
	 * {@inheritDoc}
	 */
	public void removingSourceConnection(ConnectionEditPart connection, int index) {
		IFigure figure = connection.getFigure();
		figure.removeFigureListener(figureListener);
	}

	/**
	 * {@inheritDoc}
	 */
	public void removingTargetConnection(ConnectionEditPart connection, int index) {
		IFigure figure = connection.getFigure();
		figure.removeFigureListener(figureListener);
	}

	/**
	 * {@inheritDoc}
	 */
	public void sourceConnectionAdded(ConnectionEditPart connection, int index) {
		IFigure figure = connection.getFigure();
		figure.addFigureListener(figureListener);
	}

	/**
	 * {@inheritDoc}
	 */
	public void targetConnectionAdded(ConnectionEditPart connection, int index) {
		IFigure figure = connection.getFigure();
		figure.addFigureListener(figureListener);
	}

}
